package org.example.io.handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.example.io.protocol.Packet;
import org.example.io.protocol.packet.PacketCodec;

import java.util.List;

public class PacketDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        // in 转成 Packet
        Packet packet = PacketCodec.INSTANCE.decode(in);
        out.add(packet);
    }
}
